
/*
 * Copyright 2002-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2019原作者。
 *
 *根据Apache许可证2.0版（“许可证”）许可；
 *除非符合许可证的规定，否则您不得使用此文件。
 *您可以在以下网址获取许可证副本
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，否则软件
 *根据许可证分发是在“按原样”的基础上分发的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限的特定语言，请参阅许可证
 *许可证下的限制。
 */

package org.springframework.context.annotation;

import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.core.type.AnnotationMetadata;

/**
 * Interface to be implemented by types that register additional bean definitions when
 * processing @{@link Configuration} classes. Useful when operating at the bean definition
 * level (as opposed to {@code @Bean} method/instance level) is desired or necessary.
 *
 * <p>Along with {@code @Configuration} and {@link ImportSelector}, classes of this type
 * may be provided to the @{@link Import} annotation (or may also be returned from an
 * {@code ImportSelector}).
 *
 * <p>An {@link ImportBeanDefinitionRegistrar} may implement any of the following
 * {@link org.springframework.beans.factory.Aware Aware} interfaces, and their respective
 * methods will be called prior to {@link #registerBeanDefinitions}:
 * <ul>
 * <li>{@link org.springframework.context.EnvironmentAware EnvironmentAware}</li>
 * <li>{@link org.springframework.beans.factory.BeanFactoryAware BeanFactoryAware}
 * <li>{@link org.springframework.beans.factory.BeanClassLoaderAware BeanClassLoaderAware}
 * <li>{@link org.springframework.context.ResourceLoaderAware ResourceLoaderAware}
 * </ul>
 *
 * <p>Alternatively, the class may provide a single constructor with one or more of
 * the following supported parameter types:
 * <ul>
 * <li>{@link org.springframework.core.env.Environment Environment}</li>
 * <li>{@link org.springframework.beans.factory.BeanFactory BeanFactory}</li>
 * <li>{@link java.lang.ClassLoader ClassLoader}</li>
 * <li>{@link org.springframework.core.io.ResourceLoader ResourceLoader}</li>
 * </ul>
 *
 * <p>See implementations and associated unit tests for usage examples.
 *
 * @author Chris Beams
 * @author Juergen Hoeller
 * @since 3.1
 * @see Import
 * @see ImportSelector
 * @see Configuration
 */
/**
 *当
 *正在处理@｛@link配置｝类。在bean定义下操作时很有用
 *级别（与{@code@Bean}方法/实例级别相反）是需要的或必要的。
 *
 *<p>连同｛@code@Configuration｝和｛@link ImportSelector｝，这类
 *可以提供给@｛@link Import｝注释（也可以从
 *｛@code ImportSelector｝）。
 *
 *<p>｛@link ImportBeanDefinitionRegistrar｝可以实现以下任何一项
 *｛@link org.springframework.beans.factory.Aware Aware｝接口及其各自
 *方法将在｛@link#registerBeanDefinitions｝之前调用：
 *＜ul＞
 *<li>｛@link org.springframework.context.EnvironmentAware环境感知｝</li>
 *＜li＞｛@link org.springframework.beans.factory.BeanFactory软件BeanFactory软件｝
 *<li>｛@link org.springframework.beans.factory.BeanClassLoaderAware BeanClassLoader Aware｝
 *<li>｛@link org.springframework.context.ResourceLoaderAware资源加载器Aware｝
 *</ul>
 *
 *<p>或者，类可以提供一个具有以下一个或多个的构造函数
 *以下支持的参数类型：
 *＜ul＞
 *＜li＞｛@link org.springframework.core.env.env.Environment环境｝</li>
 *＜li＞｛@link org.springframework.beans.factory.BeanFactory BeanFactory｝</li>
 *＜li＞｛@link java.lang.ClassLoader类加载器｝</li>
 *＜li＞｛@link org.springframework.core.io.ResourceLoader资源加载器｝</li>
 *</ul>
 *
 *<p>有关使用示例，请参阅实现和相关的单元测试。
 *
 *@作者Chris Beams
 *@作者Juergen Hoeller
 *@自3.1起
 *@请参阅导入
 *@参见ImportSelector
 *@请参阅配置
 */
public interface ImportBeanDefinitionRegistrar {

	/**
	 * Register bean definitions as necessary based on the given annotation metadata of
	 * the importing {@code @Configuration} class.
	 * <p>Note that {@link BeanDefinitionRegistryPostProcessor} types may <em>not</em> be
	 * registered here, due to lifecycle constraints related to {@code @Configuration}
	 * class processing.
	 * <p>The default implementation delegates to
	 * {@link #registerBeanDefinitions(AnnotationMetadata, BeanDefinitionRegistry)}.
	 * @param importingClassMetadata annotation metadata of the importing class
	 * @param registry current bean definition registry
	 * @param importBeanNameGenerator the bean name generator strategy for imported beans:
	 * {@link ConfigurationClassPostProcessor#IMPORT_BEAN_NAME_GENERATOR} by default, or a
	 * user-provided one if {@link ConfigurationClassPostProcessor#setBeanNameGenerator}
	 * has been set. In the latter case, the passed-in strategy will be the same used for
	 * component scanning in the containing application context (otherwise, the default
	 * component-scan naming strategy is {@link AnnotationBeanNameGenerator#INSTANCE}).
	 * @since 5.2
	 * @see ConfigurationClassPostProcessor#IMPORT_BEAN_NAME_GENERATOR
	 * @see ConfigurationClassPostProcessor#setBeanNameGenerator
	 */
	/**
	 *根据给定的注释元数据，根据需要注册bean定义
	 *导入｛@code@Configuration｝类。
	 *<p>请注意，｛@link BeanDefinitionRegistryPostProcessor｝类型可能是<em>而不是</em>
	 *由于与｛@code@Configuration｝相关的生命周期限制，在此处注册
	 *类处理。
	 *＜p＞默认实现委托给
	 *｛@link#registerBeanDefinitions（注解元数据，BeanDefinitionRegistry）｝。
	 *@param importingClassMetadata导入类的注释元数据
	 *@param registry当前bean定义注册表
	 *@param importBeanNameGenerator导入bean的bean名称生成器策略：
	 *｛@link ConfigurationClassPostProcessor#IMPORT_BEAN_NAME_GENERATOR｝默认情况下，或
	 *如果｛@link ConfigurationClassPostProcessor#setBeanNameGenerator｝，则用户提供了一个
	 *已设置。在后一种情况下，传入策略将与用于
	 *包含应用程序上下文中的组件扫描（否则，默认
	 *组件扫描命名策略为｛@link AnnotationBeanNameGenerator#INSTANCE｝）。
	 *@自5.2起
	 *@请参阅ConfigurationClassPostProcessor#IMPORT_BEAN_NAME_GENERATOR
	 *@请参阅ConfigurationClassPostProcessor#setBeanNameGenerator
	 */
	default void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry,
			BeanNameGenerator importBeanNameGenerator) {

		registerBeanDefinitions(importingClassMetadata, registry);
	}

	/**
	 * Register bean definitions as necessary based on the given annotation metadata of
	 * the importing {@code @Configuration} class.
	 * <p>Note that {@link BeanDefinitionRegistryPostProcessor} types may <em>not</em> be
	 * registered here, due to lifecycle constraints related to {@code @Configuration}
	 * class processing.
	 * <p>The default implementation is empty.
	 * @param importingClassMetadata annotation metadata of the importing class
	 * @param registry current bean definition registry
	 */
	/**
	 *根据给定的注释元数据，根据需要注册bean定义
	 *导入｛@code@Configuration｝类。
	 *<p>请注意，｛@link BeanDefinitionRegistryPostProcessor｝类型可能是<em>而不是</em>
	 *由于与｛@code@Configuration｝相关的生命周期限制，在此处注册
	 *类处理。
	 *＜p＞默认实现为空。
	 *@param importingClassMetadata导入类的注释元数据
	 *@param registry当前bean定义注册表
	 */
	default void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
	}

}
